// pages/detail/detail.js
import Config from '../../config.js'


Page({

  /**
   * 页面的初始数据
   */
  data: {
    result:{},
    name:null

  },
  onLoad: function (options) {
    
    console.log(options)
    //获取从首页传递过来的name
    let nameWord = options.name
    console.log(nameWord)

    //转码后的name
    let name = encodeURIComponent(nameWord)
    console.log(name)

    
    this.setData({
      name:name
    })
    this.getData( this.data.name )

  },

getData( name ){
  wx.showLoading({
    title: '正在加载',
  })

  wx.request({
    url: `${Config.api}?key=f533cb0db61c8c5a676194769d4f9680&consName=${name}&type=today`,
    success: (res) => {
      console.log( res.data )

       //请求成功，让图标消失
      wx.hideLoading()
     
      this.setData({
        result:res.data      
      })
    }
  })
}

  
})